import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class AlertUtilAlertAction extends StatelessWidget {
  const AlertUtilAlertAction({
    super.key,
    this.widget,
    this.text = '',
    this.isDestructiveAction = false,
    this.callback,
  });

  final Widget? widget;
  final String text;
  final bool isDestructiveAction;
  final VoidCallback? callback;

  @override
  Widget build(BuildContext context) {
    return CupertinoDialogAction(
      isDefaultAction: false,
      isDestructiveAction: isDestructiveAction,
      onPressed: () {
        Navigator.of(context).pop();
        if (callback != null) callback!();
      },
      child: widget ??
          Text(
            text,
            style: TextStyle(
              color: isDestructiveAction ? Colors.red : Colors.black,
            ),
          ),
    );
  }
}
